﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="Web.Index" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>OA系统-莞香投资</title>
    <link href="ExtJs/resources/css/ext-all-neptune.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        #divHeader,#divHeader *{margin: 0;padding:0;}
        #divHeader{width:100%;background:#4b9cd7;overflow: hidden;}
        a{ text-decoration: none;color: #0066CC;}
    </style>
    <script src="ExtJs/bootstrap.js" type="text/javascript"></script>
    <script src="ExtJs/locale/ext-lang-zh_CN.js" type="text/javascript"></script>
    
    <script src="ExtJs/Common/Common.js" type="text/javascript"></script>
    <script src="ExtJs/Common/FormHandler.js" type="text/javascript"></script>

    <script src="ExtJs/Ux/TreePicker.js" type="text/javascript"></script>
<script type="text/javascript">
    Ext.define('MenuModel', {
        extend: 'Ext.data.Model',
        fields: ['id', 'text', 'iconCls']
    });
    var menuStore = Ext.create('Ext.data.TreeStore', {
        model: 'MenuModel',
        proxy: {
            type: 'ajax',
            url: '/Menu.mvc/GetMenu'
        }
    });
    menuStore.load();

    Ext.define('ShengRiModel', {
        extend: 'Ext.data.Model',
        fields: ["Id", "Name", "BornDate"]
    });
    var shengRiStore = Ext.create('Ext.data.Store',
        {
            model: 'ShengRiModel',
            proxy: {
                type: 'ajax',
                url: '/EmpProfile.mvc/GetCelebrate',
                reader: {
                    type: 'json'
                }
            },
            autoLoad: true
        });
    var shengRiGrid = Ext.create('Ext.grid.Panel',{
        id: 'shengRiGrid', border: false, store: shengRiStore, columns: [
            {
                header: '寿星', width:80, dataIndex: 'Name',
                renderer: function (value, cellmeta, currRow) {
                    return "<img src='../Content/images/icons/cake.png' width='14px' height='14px'>" + value;
                }
            }, {
                header: '日期',dataIndex: 'BornDate',
                renderer: function (value) {
                    return Ext.Date.format(eval("new " + value.substr(1, value.length - 2)), "m.d");
                }
            }], hideHeaders: true,width:140
    });
    shengRiGrid.on("itemclick", rowClickSR);
    function rowClickSR(obj, record, item, index, e, eOpts) {
        window.open('BirthdayBless.aspx?empId=' + record.data.Id);
    }

    //#region Tab0 5部分
    Ext.define('GongGaoModel', {
        extend: 'Ext.data.Model',
        fields: ["Id", "Pid", "Name", "Type", "RealName", "Size", "CreatTime", "OwnerId", "FileClass", "OrderNo", "LastUpdateTime", "LastUpdaterId", "StatusId"]
    });
    var GongGaoStore = Ext.create('Ext.data.Store',
        {
            model: 'GongGaoModel',
            proxy: {
                type: 'ajax',
                url: '/File.mvc/GetLatestNotices',
                reader: {
                    type: 'json'
                }
            },
            autoLoad: true
        });
    var GongGaoGrid = Ext.create('Ext.grid.Panel', {
        id: 'GongGaoGrid', title: '通知公告', margin: 5, autoScroll: true, border: true, store: GongGaoStore, columns: [
            {
                header: '标题',dataIndex: 'Name',flex:1,
                renderer: function (value, cellmeta, currRow) {
                    var title = value;
                    var retStr = "<a href='FileViewer.htm?FileClass=2&docRealName=" + currRow.data.RealName + "' target='_blank' onclick='return DocUsedLog(" + currRow.data.Id + ",0);'>" + title + "</a>";
                    if (currRow.data.StatusId == 0) {
                        retStr = "<img src='../Content/images/home/zuixindongtai.gif' width='28px' height='14px'>" + retStr;
                    } else {
                        retStr = "<img src='../Content/images/home/news6.gif' width='14px' height='14px'>" + retStr;
                    }
                    return retStr;
                }
            }, {
                header: '日期', dataIndex: 'CreatTime', width:90,
                renderer: function (value) {
                    return Ext.Date.format(eval("new " + value.substr(1, value.length - 2)), "Y.m.d");
                }
            }], hideHeaders: true, height: 201, columnWidth: 0.5, tools: [{
                type: 'refresh',
                handler: function () {
                    GongGaoStore.reload();
                }
            }]
    });

    Ext.define('DaiDuModel', {
        extend: 'Ext.data.Model',
        fields: ["Id", "Name", "Type", "RealName", "OwnerId", "Pid", "AuthDate", "AuthLevel", "OriAuthor", "From"]
    });
    var DaiDuStore = Ext.create('Ext.data.Store',
        {
            model: 'DaiDuModel',
            proxy: {
                type: 'ajax',
                url: '/File.mvc/GetUnReaded',
                reader: {
                    type: 'json'
                }
            },
            autoLoad: true
        });
    var DaiDuGrid = Ext.create('Ext.grid.Panel', {
        id: 'DaiDuGrid', title: '待读文件', margin: 5, autoScroll: true, border: true, store: DaiDuStore, columns: [
            {
                header: '文件名称',dataIndex: 'Name',flex:1,
                renderer: function (value, cellmeta, currRow) {
                    return "<img src='../Content/images/home/news6.gif' width='14px' height='14px'><a href='FileDownload.aspx?fileId=" + currRow.data.Id + "' target='_blank' onclick='return DocUsedLog(" + currRow.data.Id + ",0);'>" + value + "</a>";
                }
            }, {header: '作者', width: 60, dataIndex: 'OriAuthor'
            }, {
                header: '授权时间', width:90, dataIndex: 'AuthDate',
                renderer: function (value) {
                    return Ext.Date.format(eval("new " + value.substr(1, value.length - 2)), "Y.m.d");
                }
            }, {
                header: "操作", width:50, dataIndex: "Id",
                renderer: function (value, cellmeta, currRow, b, c, d, e, f, g) {
                    var returnArr = [];
                    if (currRow.data.Type != 'dir') {
                        if ('doc,xls'.indexOf(currRow.data.Type) >= 0) {
                            returnArr.push('<a href="FileViewer.htm?FileClass=0&docRealName=' + currRow.data.RealName + '" target="_blank" onclick="return DocUsedLog(' + currRow.data.Id + ',0);">查看</a>');
                        } else {
                            returnArr.push('<a href="FileDownload.aspx?fileId=' + currRow.data.Id + '" target="_blank" onclick="return DocUsedLog(' + currRow.data.Id + ',0);">下载</a>');
                        }
                    }
                    return returnArr.join("&nbsp;&nbsp;");
                }
            }], height: 201, columnWidth: 0.5, tools: [{
                type: 'refresh',
                handler: function () {
                    DaiDuStore.reload();
                }
            }]
    });

    Ext.define('DaiBanModel', {
        extend: 'Ext.data.Model',
        fields: ["FormNo", "ReqTypeName", "EmpId", "Name", "ReqDate"]
    });
    var DaiBanStore = Ext.create('Ext.data.Store',
        {
            model: 'DaiBanModel',
            proxy: {
                type: 'ajax',
                url: '/Sign.mvc/GetSigningNodes',
                reader: {
                    type: 'json'
                }
            },
            autoLoad: true
        });
    var DaiBanGrid = Ext.create('Ext.grid.Panel', {
        id: 'DaiBanGrid', title: '申请签核', margin: 5, autoScroll: true, border: true, store: DaiBanStore, columns: [
            {
                header: '申请类别',flex:1, dataIndex: 'ReqTypeName',
                renderer: function (value, cellmeta, currRow) {
                    return "<a href='#' onclick='return SignWin(\"" + currRow.data.FormNo + "\",true,true);'>" + value + "</a>";
                }
            }, {
                header: '申请人', width:80, dataIndex: 'Name'
            }, {
                header: '申请时间', width:90, hidden: false, dataIndex: 'ReqDate',
                renderer: function (value) {
                    return Ext.Date.format(eval("new " + value.substr(1, value.length - 2)), "Y.m.d");
                }
            }], hideHeaders: false, height: 394, columnWidth: 0.3, tools: [{
                type: 'refresh',
                handler: function () {
                    DaiBanStore.reload();
                }
            }]
    });

    Ext.define('DongTaiModel', {
        extend: 'Ext.data.Model',
        fields: ["FormNo", "ReqTypeName", "EmpId", "Name", "ReqDate", "StatusId", "CheckNode"]
    });
    var DongTaiStore = Ext.create('Ext.data.Store',
        {
            model: 'DongTaiModel',
            proxy: {
                type: 'ajax',
                url: '/Sign.mvc/GetSignStatus',
                reader: {
                    type: 'json'
                }
            },
            autoLoad: true
        });
    var DongTaiGrid = Ext.create('Ext.grid.Panel', {
        id: 'DongTaiGrid', title: '申请状态', margin: 5, autoScroll: true, border: true, store: DongTaiStore, columns: [
            {
                header: '申请类别', width:100, dataIndex: 'ReqTypeName',
                renderer: function (value, cellmeta, currRow) {
                    return "<a href='#' onclick='return SignWin(\"" + currRow.data.FormNo + "\",true,true);'>" + value + "</a>";
                }
            }, {header: '申请人', width:80, dataIndex: 'Name'
            }, {header: '申请时间', width:90,dataIndex: 'ReqDate',
                renderer: function (value) {
                    return Ext.Date.format(eval("new " + value.substr(1, value.length - 2)), "Y.m.d");
                }
            }, {header: '状态', dataIndex: 'StatusId',flex:1,
                renderer: function (value, cellmeta, currRow) {
                    var status;
                    switch (value) {
                    case 1: status = currRow.data.CheckNode; break;
                    case 2: status = "通过"; break;
                    case 3: status = currRow.data.CheckNode + " 退件"; break;
                    default: status = "--"; break;
                    }
                    return status;
                }
            }],height:394, columnWidth: 0.4, tools: [{
                type: 'refresh',
                handler: function () {
                    DongTaiStore.reload();
                }
            }]
    });

    Ext.define('TiXingModel', {
        extend: 'Ext.data.Model',
        fields: ["Affair", "RemindTime"]
    });
    var TiXingStore = Ext.create('Ext.data.Store',
        {
            model: 'TiXingModel',
            proxy: {
                type: 'ajax',
                url: '/Audition.mvc/GetRemind',
                reader: {
                    type: 'json'
                }
            },
            autoLoad: true
        });
    var TiXingGrid = Ext.create('Ext.grid.Panel', {
        id: 'TiXingGrid', title: '事务提醒', margin: 5, autoScroll: true, border: true, store: TiXingStore, columns: [
            {
                header: '事务',flex:1, dataIndex: 'Affair',
                renderer: function (value, cellmeta, currRow) {
                    return "<img src='../Content/images/home/notice2.gif' width='14px' height='14px'>" + value;
                }
            }, {
                header: '时间', width:140, hidden: false, dataIndex: 'RemindTime',
                renderer: function (value) {
                    return Ext.Date.format(eval("new " + value.substr(1, value.length - 2)), "Y.m.d H:i:s");
                }
            }], height: 394, columnWidth: 0.3, tools: [{
                type: 'refresh',
                handler: function () {
                    TiXingStore.reload();
                }
            }]
    });

    function refreshGrid() {
        GongGaoStore.reload();
        DaiDuStore.reload();
        DaiBanStore.reload();
        DongTaiStore.reload();
        TiXingStore.reload();
    }
    setInterval(refreshGrid, 600000);//10分钟刷新一次
    //#endregion

    var tabPanel = Ext.create('Ext.tab.Panel', {
        region: 'center',
        deferredRender: false,
        activeTab: 0,
        items: [Ext.create('Ext.Panel', {
            title: '桌面',layout: 'column',autoScroll:true,
            items: [GongGaoGrid, DaiDuGrid, DaiBanGrid, DongTaiGrid, TiXingGrid]
        })]
    });

    Ext.onReady(function () {
        Ext.QuickTips.init();

        // NOTE: This is an example showing simple state management. During development,
        // it is generally best to disable state management as dynamically-generated ids
        // can change across page loads, leading to unpredictable results.  The developer
        // should ensure that stable state ids are set for stateful components in real apps.
        Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider'));

        var viewport = Ext.create('Ext.Viewport', {
            id: 'border-example',
            layout: 'border',
            items: [
                {
                // lazily created panel (xtype:'panel' is default)
                    region: 'north',
                    contentEl: 'divHeader',
                    split: false,
                    collapsible: false,
                    collapsed: false,
                    margins:'0'
                },
                Ext.create('Ext.tree.Panel', {
                    region: 'west',
                    title: '功能菜单', rootVisible: false,
                    split: true,
                    width:180,
                    minWidth: 180,
                    maxWidth: 180,
                    collapsible: true,
                    animCollapse: true,
                    margins: '0 0 0 0',
                    store: menuStore
                }),
                tabPanel,
                {
                    region: 'east',
                    title: '生日祝福',
                    animCollapse: true,
                    collapsible: true,
                    split: true,
                    width:160, // give east and west regions a width
                    minSize: 160,
                    maxSize: 160,
                    margins: '0',
                    items: shengRiGrid, autoScroll: true
                }]
        });
        var leftmenu = viewport.items.getAt(1);
        leftmenu.on('itemclick', function (menu, record, item, index, e, eOpts) {
            if (record.isLeaf()) {
                e.preventDefault();

                openTab(record);
            }
        });

        function openTab(record) {
            var title = record.data.text;
            var id = record.internalId;
            var tab = tabPanel.getComponent(id);
            if (tab) {
                tabPanel.setActiveTab(tab);
            } else {
                if (id == 'FileMgr') {//我的文档
                    tabPanel.add({
                        id: id,title: title,closable: true,
                        html: '<iframe src="PersonalMain.aspx" frameborder="0" width=100% height=100%></iframe>'
                    }).show();
                } else if (id == 'AuthFileMgr') {//授权文档
                    tabPanel.add({
                        id: id,title: title,closable: true,
                        html: '<iframe src="AuthedMain.aspx" frameborder="0" width=100% height=100%></iframe>'
                    }).show();
                } else if (id == 'ShareMgr') {//共享文档
                    tabPanel.add({
                        id: id,title: title,closable: true,
                        html: '<iframe src="ShareMain.aspx" frameborder="0" width=100% height=100%></iframe>'
                    }).show();
                } else if (id == 'VehicleMgr') {//车辆申请
                    jsLoader.onsuccess = function () {
                        tabPanel.add(new Oa.VehicleGrid({
                            id: id, title: title, closable: true
                        })).show();
                    }
                    jsLoader.load("ExtJs/FormMgr/VehicleMgr.js");
                } else if (id == 'EvectionMgr') {//出差申请
                    jsLoader.onsuccess = function () {
                        tabPanel.add(new Oa.EvectionGrid({
                            id: id, title: title, closable: true
                        })).show();
                    }
                    jsLoader.load("ExtJs/FormMgr/EvectionMgr.js");
                } else if (id == 'OvertimeMgr') {//加班申请
                    jsLoader.onsuccess = function () {
                        tabPanel.add(new Oa.OvertimeGrid({
                            id: id, title: title, closable: true
                        })).show();
                    }
                    jsLoader.load("ExtJs/FormMgr/OvertimeMgr.js");
                } else if (id == 'VacationMgr') {//请假申请
                    jsLoader.onsuccess = function () {
                        tabPanel.add(new Oa.VacationGrid({
                            id: id, title: title, closable: true
                        })).show();
                    }
                    jsLoader.load("ExtJs/FormMgr/VacationMgr.js");
                } else if (id == 'MeetingRoomMgr') {//会议室申请
                    jsLoader.onsuccess = function () {
                        tabPanel.add(new Oa.MeetingRoomGrid({
                            id: id, title: title, closable: true
                        })).show();
                    }
                    jsLoader.load("ExtJs/FormMgr/MeetingRoomMgr.js");
                } else if (id == 'PerchaseMgr') {//采购申请
                    jsLoader.onsuccess = function () {
                        tabPanel.add(new Oa.PerchaseGrid({
                            id: id, title: title, closable: true
                        })).show();
                    }
                    jsLoader.load("ExtJs/FormMgr/PerchaseMgr.js");
                } else if (id == 'ReceptionMgr') {//商务接待申请
                    jsLoader.onsuccess = function () {
                        tabPanel.add(new Oa.ReceptionGrid({
                            id: id, title: title, closable: true
                        })).show();
                    }
                    jsLoader.load("ExtJs/FormMgr/ReceptionMgr.js");
                } else if (id == 'NoticeMgr') {//通知公告
                    tabPanel.add({
                        id: id,title: title,closable: true,
                        html: '<iframe src="NoticeList.aspx" frameborder="0" width=100% height=100%></iframe>'
                    }).show();
                } else if (id == 'CardMgr') {//考勤打卡
                    tabPanel.add({
                        id: id, title: title, closable: true,
                        html: '<iframe src="CardLog.aspx" frameborder="0" width=100% height=100%></iframe>'
                    }).show();
                } else if (id == 'DutyMgr') {//值班维护
                    tabPanel.add({
                        id: id, title: title, closable: true,
                        html: '<iframe src="DutyList.aspx" frameborder="0" width=100% height=100%></iframe>'
                    }).show();
                } else if (id == 'ContactMgr') {//公共通讯薄
                    tabPanel.add({
                        id: id, title: title, closable: true,
                        html: '<iframe src="Contact.aspx" frameborder="0" width=100% height=100%></iframe>'
                    }).show();
                } else if (id == 'DocNoMgr') {//文件号维护
                    jsLoader.onsuccess = function () {
                        tabPanel.add(new Oa.DocNoGrid({
                            id: id, title: title, closable: true
                        })).show();
                    }
                    jsLoader.load("ExtJs/FormMgr/DocNoMgr.js");
                } else if (id == 'AssetMgr') {//资产维护
                    jsLoader.onsuccess = function () {
                        tabPanel.add(new Oa.AssetGrid({
                            id: id, title: title, closable: true
                        })).show();
                    }
                    jsLoader.load("ExtJs/FormMgr/AssetMgr.js");
                } else if (id == 'AnnualMgr') {//年假查询
                    jsLoader.onsuccess = function () {
                        tabPanel.add(new Oa.AnnualGrid({
                            id: id, title: title, closable: true
                        })).show();
                    }
                    jsLoader.load("ExtJs/FormMgr/AnnualMgr.js");
                } else if (id == 'DeptMgr') {//部门管理
                    tabPanel.add({
                        id: id,title: title,closable: true,
                        html: '<iframe src="DeptList.aspx" frameborder="0" width=100% height=100%></iframe>'
                    }).show();
                } else if (id == 'PositionMgr') {//职位维护
                    jsLoader.onsuccess = function () {
                        tabPanel.add(new Oa.PositionGrid({
                            id: id, title: title, closable: true
                        })).show();
                    }
                    jsLoader.load("ExtJs/FormMgr/PositionMgr.js");
                } else if (id == 'EmpProfileMgr') {//员工档案管理
                    jsLoader.onsuccess = function () {
                        tabPanel.add(new Oa.EmpProfileGrid({
                            id: id, title: title, closable: true
                        })).show();
                    }
                    jsLoader.load("ExtJs/FormMgr/EmpProfileMgr.js");
                } else if (id == 'InviteMgr') {//招聘申请
                    jsLoader.onsuccess = function () {
                        tabPanel.add(new Oa.InviteGrid({
                            id: id, title: title, closable: true
                        })).show();
                    }
                    jsLoader.load("ExtJs/FormMgr/InviteMgr.js");
                } else if (id == 'AuditionMgr') {//面试维护
                    jsLoader.onsuccess = function () {
                        tabPanel.add(new Oa.AuditionGrid({
                            id: id, title: title, closable: true
                        })).show();
                    }
                    jsLoader.load("ExtJs/FormMgr/AuditionMgr.js");
                }  else if (id == 'TrainNeedMgr') {//培训需求
                    jsLoader.onsuccess = function () {
                        tabPanel.add(new Oa.TrainNeedGrid({
                            id: id, title: title, closable: true
                        })).show();
                    }
                    jsLoader.load("ExtJs/FormMgr/TrainNeedMgr.js");
                } else if (id == 'TrainSchemeMgr') {//培训计划
                    tabPanel.add({
                        id: id,title: title,closable: true,
                        html: '<iframe src="TrainSchemeList.aspx" frameborder="0" width=100% height=100%></iframe>'
                    }).show();
                }  else if (id == 'DailyMgr') {//工作日志
                    tabPanel.add({
                        id: id,title: title,closable: true,
                        html: '<iframe src="DailyList.aspx" frameborder="0" width=100% height=100%></iframe>'
                    }).show();
                } else if (id == 'WeeklyMgr') {//周报
                    jsLoader.onsuccess = function () {
                        tabPanel.add(new Oa.WeeklyGrid({
                            id: id, title: title, closable: true
                        })).show();
                    }
                    jsLoader.load("ExtJs/FormMgr/WeeklyMgr.js");
                } else if (id == 'CardOnlineMgr') {//在线打卡
                    cardOnline();
                } else if (id == 'UserSelfMgr') {//个人信息
                    var url = 'EmpContactEdit.aspx';
                    var retVal = window.showModalDialog(url, window, 'dialogWidth=550px;dialogHeight=250px;status=no;help=no;');
                    if (retVal != undefined && retVal.indexOf('Succeed') >= 0) {
                        alert("个人信息修改成功~");
                    }
                } else if (id == 'ChgPwdWin') {//修改密码
                    jsLoader.onsuccess = function () {
                        new Oa.PasswordWin().show();
                    }
                    jsLoader.load("ExtJs/FormMgr/PasswordMgr.js");
                } else if (id == 'QuestionMgr') {//题库维护
                    jsLoader.onsuccess = function () {
                        tabPanel.add(new Oa.ExamTypeGrid({
                            id: id, title: title, closable: true
                        })).show();
                    }
                    jsLoader.load("ExtJs/FormMgr/ExamTypeMgr.js");
                } else if (id == 'IMGradeMgr') {//居间级别
                    jsLoader.onsuccess = function () {
                        tabPanel.add(new Oa.IMGradeGrid({
                            id: id, title: title, closable: true
                        })).show();
                    }
                    jsLoader.load("ExtJs/FormMgr/IMGradeMgr.js");
                } else if (id == 'IMCoopschemeMgr') {//居间合作方案
                    jsLoader.onsuccess = function () {
                        tabPanel.add(new Oa.IMCoopschemeGrid({
                            id: id, title: title, closable: true
                        })).show();
                    }
                    jsLoader.load("ExtJs/FormMgr/IMCoopschemeMgr.js");
                } else if (id == 'GXPackageMgr') {//财富套餐
                    jsLoader.onsuccess = function () {
                        tabPanel.add(new Oa.GXPackageGrid({
                            id: id, title: title, closable: true
                        })).show();
                    }
                    jsLoader.load("ExtJs/FormMgr/GXPackageMgr.js");
                } else if (id == 'IMProfileMgr') {//居间档案
                    jsLoader.onsuccess = function () {
                        tabPanel.add(new Oa.IMProfileGrid({
                            id: id, title: title, closable: true
                        })).show();
                    }
                    jsLoader.load("ExtJs/FormMgr/IMProfileMgr.js");
                } else if (id == 'InvestorMgr') {//客户档案
                    jsLoader.onsuccess = function () {
                        tabPanel.add(new Oa.InvestorGrid({
                            id: id, title: title, closable: true
                        })).show();
                    }
                    jsLoader.load("ExtJs/FormMgr/InvestorMgr.js");
                } else if (id == 'RoleMgr') {//角色管理
                    jsLoader.onsuccess = function () {
                        tabPanel.add(new Oa.RoleGrid({
                            id: id, title: title, closable: true
                        })).show();
                    }
                    jsLoader.load("ExtJs/FormMgr/RoleMgr.js");
                } else {
                    Ext.Msg.alert('提示:', '该功能正在实现中,敬请期待...');
                }
            }
        }
    });
</script>
</head>
<body>
<div id="divHeader" class="x-hide-display">
    <img src="Images/logo.gif" style="float:left;margin:6px auto 6px 60px;"/>
	<div style="float:right;color:#014994;font-weight:bolder;margin:33px 14px auto auto;">
		当前登录工号:<%=jobNo %> &nbsp;<a onclick="return loginOut();" href="#" style="color:#fef301;">[注销]</a>
	</div>
</div>
</body>
</html>